---
title: Tic Tac Toe Battle
---

Tic Tac Toe Battle is a tic-tac-toe game where multiple AI agents compete against each other, demonstrating the power of multi-agent systems in complex game environments.

### Key Capabilities
- Multi-Agent System: Features X and O Piece Agents for move selection
- Move Validation: Dedicated Board Agent ensures game rule compliance
- Game Coordination: Master Agent oversees the game flow and end conditions
- Interactive UI: Built with Streamlit for real-time game visualization

<video
  autoPlay
  muted
  controls
  className="w-full aspect-video"
  src="/videos/tic-tac-toe.mp4"
></video>

### System Components
- X Piece Agent: Strategizes and selects moves for X pieces
- O Piece Agent: Controls and determines moves for O pieces
- Board Agent: Validates all proposed moves against game rules
- Master Agent: Coordinates the game flow and monitors game status

### Advanced Features
The system demonstrates complex agent interactions where each AI component has a specific role. The agents communicate and coordinate to create a complete tic-tac-toe experience, showcasing how multiple specialized AIs can work together effectively.

### Code
The complete code is available in the [Agno repository](https://github.com/agno-agi/agno/tree/main/cookbook/examples/streamlit_apps/tic_tac_toe).

### Usage
<Steps>
  <Step title="Clone the repository">
    ```bash
    git clone https://github.com/agno-agi/agno.git
    cd agno
    ```
  </Step>

  <Step title="Create a Virtual Environment">
    ```bash
    python3 -m venv .venv
    source .venv/bin/activate  # On Windows use: .venv\Scripts\activate
    ```
  </Step>

  <Step title="Install Dependencies">
    ```bash
    pip install -r cookbook/examples/streamlit_apps/tic_tac_toe/requirements.txt
    ```
  </Step>

  <Step title="Set up API Keys">
    The Tic Tac Toe Battle supports multiple AI models:

    ```bash
    # Required for OpenAI models (GPT-4, GPT-3.5)
    export OPENAI_API_KEY=your_api_key_here
    
    # Optional - for additional models
    export ANTHROPIC_API_KEY=your_api_key_here  # For Claude models
    export GOOGLE_API_KEY=your_api_key_here     # For Gemini models
    export GROQ_API_KEY=your_api_key_here       # For Groq models
    ```
  </Step>

  <Step title="Launch the App">
    ```bash
    streamlit run cookbook/examples/streamlit_apps/tic_tac_toe/app.py
    ```
  </Step>

  <Step title="Open the App">
    Then, open http://localhost:8501 in your browser to start watching the AI agents play tic-tac-toe.
  </Step>
</Steps>

### Pro Tips
- Watch Complete Games: Observe full matches to understand agent decision-making
- Monitor Agent Interactions: Pay attention to how agents communicate and coordinate
- Try Different Models: Experiment with various AI models to see different playing styles

Need help? Join our [Discourse community](https://agno.link/community) for support!